package main

import (
	"bytes"
	"fmt"
	"os/exec"
	"strings"
	"time"
)

func main() {
	for !pull() {
	}
}

func pull() bool {
	fmt.Println(time.Now().Format("2006-01-02 15:04:05"), "git pull")
	cmd := exec.Command("git", "pull")
	var out bytes.Buffer
	cmd.Stdout = &out
	cmd.Stderr = &out
	cmd.Run()
	result := out.String()
	result = strings.Trim(result, "\r")
	result = strings.Trim(result, "\n")
	result = strings.TrimSpace(result)
	fmt.Println(result)
	if result == "Already up to date." {
		return true
	}
	return false
}
